<?php
namespace app\bankcard\controller;

use tp5_lib\common\controller\TestBaseController;
use tp5_lib\bankcard\model\BankcardModel;
use tp5_lib\user\model\UserModel;

class TestController extends TestBaseController
{
    public function index()
    {
        return $this->fetch();
    }
    public function doUpload()
    {
        $data=input();
        $data["time"]=time();
        $user=new UserModel();
        if(!$user->where(["id"=>$data["user_id"]])->find()){
            $this->error("用户不存在");
        }
        $model=new BankcardModel();
        if(!$model->check($data["card_id"])){
            $this->error("请输入正确的银行卡号");
        }
        if(!$model->db()->insert($data)){
            $this->error($model->getError());
        }
        $this->success();
    }
}
